/**
 * 
 */
package com.laozhao.dreamframe.view;

import java.util.Vector;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;

/**
 * @author dozhao
 * 
 */
public class DreamTable extends JTable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -50280546040376164L;

	/**
	 * 
	 */
	public DreamTable() {
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param dm
	 */
	public DreamTable(TableModel dm) {
		super(dm);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param dm
	 * @param cm
	 */
	public DreamTable(TableModel dm, TableColumnModel cm) {
		super(dm, cm);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param numRows
	 * @param numColumns
	 */
	public DreamTable(int numRows, int numColumns) {
		super(numRows, numColumns);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param rowData
	 * @param columnNames
	 */
	public DreamTable(Vector rowData, Vector columnNames) {
		super(rowData, columnNames);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param rowData
	 * @param columnNames
	 */
	public DreamTable(Object[][] rowData, Object[] columnNames) {
		super(rowData, columnNames);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param dm
	 * @param cm
	 * @param sm
	 */
	public DreamTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm) {
		super(dm, cm, sm);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param dm
	 * @param cm
	 * @param sm
	 */
	public DreamTable(DreamTableModel<?> dm) {
		super(dm);
		for (int i = 0; i < getColumnCount(); i++) {
			if (dm.isColumnHide(i)) {
				// getColumnModel().getColumn(i).setWidth(0);
				TableColumn tc = getTableHeader().getColumnModel().getColumn(i);
				tc.setMaxWidth(0);
				tc.setMinWidth(0);
				tc.setPreferredWidth(0);
				tc.setWidth(0);

			}
		}
	}

	public void setDreamTable(DreamTableModel<?> dm){
		super.setModel(dm);
		for (int i = 0; i < getColumnCount(); i++) {
			if (dm.isColumnHide(i)) {
				// getColumnModel().getColumn(i).setWidth(0);
				TableColumn tc = getTableHeader().getColumnModel().getColumn(i);
				tc.setMaxWidth(0);
				tc.setMinWidth(0);
				tc.setPreferredWidth(0);
				tc.setWidth(0);

			}
		}
	}

}
